package com.theory.bind;

import java.lang.reflect.Proxy;

public class MapperProxyFactory<T> {

    public Class<T> mapperInterface;

    public MapperProxyFactory(Class<T> type) {
        mapperInterface = type;
    }

    @SuppressWarnings("unchecked")
    public T newInstance(){
        MapperProxy<T> mapperProxy = new MapperProxy<>(mapperInterface);
        return (T) Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[] { mapperInterface }, mapperProxy);
    }
}
